Update to rust master
authorAlex Crichton <alex@alexcrichton.com>
Mon, 9 Mar 2015 18:30:37 +0000 (11:30 -0700)
committerAlex Crichton <alex@alexcrichton.com>
Mon, 9 Mar 2015 18:30:37 +0000 (11:30 -0700)
21 files changed:
src/cargo/core/package_id_spec.rs
src/cargo/lib.rs
src/cargo/ops/cargo_clean.rs
src/cargo/ops/cargo_doc.rs
src/cargo/ops/cargo_new.rs
src/cargo/ops/cargo_package.rs
src/cargo/ops/cargo_read_manifest.rs
src/cargo/ops/cargo_rustc/custom_build.rs
src/cargo/ops/cargo_rustc/fingerprint.rs
src/cargo/ops/cargo_rustc/layout.rs
src/cargo/ops/cargo_rustc/mod.rs
src/cargo/ops/cargo_test.rs
src/cargo/ops/registry.rs
src/cargo/sources/git/utils.rs
src/cargo/sources/path.rs
src/cargo/sources/registry.rs
src/cargo/util/config.rs
src/cargo/util/important_paths.rs
src/cargo/util/toml.rs
src/registry/lib.rs
src/rustversion.txt

index 087d996d0eba5c511006b228577df6c5cdc84521..e65c599805ebb40b841bb4fb5414e59e8ab287b6 100644 (file)
@@ -77,7 +77,8 @@ impl PackageIdSpec {
                             (name_or_version.to_string(), Some(version))
                         }
                         None => {
-                            if name_or_version.char_at(0).is_alphabetic() {
+                            if name_or_version.chars().next().unwrap()
+                                              .is_alphabetic() {
                                 (name_or_version.to_string(), None)
                             } else {
                                 let version = try!(name_or_version.to_semver()
index e90594d9e4a8280acb5ec67357e9a03561f82357..a09b47adf654f391b40f435d1b48fa903df591d0 100644 (file)
@@ -1,6 +1,6 @@
 #![deny(unused)]
-#![feature(collections, hash, os, std_misc, unicode, core)]
-#![feature(io, path, str_words, fs, old_io, exit_status)]
+#![feature(hash, os, std_misc, unicode, core)]
+#![feature(io, path, str_words, old_io, exit_status, fs_time)]
 #![cfg_attr(test, deny(warnings))]
 
 #[cfg(test)] extern crate hamcrest;
index bbfab64c7ee4ab43fa1c94723fea49b2171d0a11..b9834526a7d9541895d3f13aa128f38404ef2b76 100644 (file)
@@ -68,11 +68,12 @@ pub fn clean(manifest_path: &Path, opts: &CleanOptions) -> CargoResult<()> {
 }
 
 fn rm_rf(path: &Path) -> CargoResult<()> {
-    if path.is_dir() {
+    let m = fs::metadata(path);
+    if m.as_ref().map(|s| s.is_dir()) == Ok(true) {
         try!(fs::remove_dir_all(path).chain_error(|| {
             human("could not remove build directory")
         }));
-    } else if path.exists() {
+    } else if m.is_ok() {
         try!(fs::remove_file(path).chain_error(|| {
             human("failed to remove build artifact")
         }));
index fd7304cafd2ffa24f9cf72ec44d9b4765dede6c4..94da98eef92fc7e73e018f5aa4f72299ecd6e6ed 100644 (file)
@@ -1,5 +1,5 @@
 use std::collections::HashSet;
-use std::io::prelude::*;
+use std::fs;
 use std::path::Path;
 use std::process::Command;
 
@@ -57,7 +57,7 @@ pub fn doc(manifest_path: &Path,
 
         let path = package.absolute_target_dir().join("doc").join(&name)
                                                     .join("index.html");
-        if path.exists() {
+        if fs::metadata(&path).is_ok() {
             open_docs(&path);
         }
     }
index 5038495bc1fb455520faef724a21893d6e9dfa4b..efb7d99e49a44700bac87ea22fb53ae716311903 100644 (file)
@@ -42,7 +42,7 @@ struct CargoNewConfig {
 
 pub fn new(opts: NewOptions, config: &Config) -> CargoResult<()> {
     let path = config.cwd().join(opts.path);
-    if path.exists() {
+    if fs::metadata(&path).is_ok() {
         return Err(human(format!("Destination `{}` already exists",
                                  path.display())))
     }
index 6bf4a931a0cda021b40eae8b017771818ac3df97..f3364737a65ef7e2992870bb828c93d8440e20e8 100644 (file)
@@ -50,7 +50,7 @@ pub fn package(manifest_path: &Path,
 
     let filename = format!("package/{}-{}.crate", pkg.name(), pkg.version());
     let dst = pkg.absolute_target_dir().join(&filename);
-    if dst.exists() { return Ok(Some(dst)) }
+    if fs::metadata(&dst).is_ok() { return Ok(Some(dst)) }
 
     let mut bomb = Bomb { path: Some(dst.clone()) };
 
@@ -104,7 +104,7 @@ fn check_metadata(pkg: &Package, config: &Config) -> CargoResult<()> {
 fn tar(pkg: &Package, src: &PathSource, config: &Config,
        dst: &Path) -> CargoResult<()> {
 
-    if dst.exists() {
+    if fs::metadata(&dst).is_ok() {
         return Err(human(format!("destination already exists: {}",
                                  dst.display())))
     }
@@ -149,7 +149,7 @@ fn run_verify(config: &Config, pkg: &Package, tar: &Path)
     let f = try!(GzDecoder::new(try!(File::open(tar))));
     let dst = pkg.root().join(&format!("target/package/{}-{}",
                                        pkg.name(), pkg.version()));
-    if dst.exists() {
+    if fs::metadata(&dst).is_ok() {
         try!(fs::remove_dir_all(&dst));
     }
     let mut archive = Archive::new(f);
index 79de52a5e61f971380b8c28d305937a60bc1f9b6..39c7f9edd4a3f5d22971ea10833e902ab1157d8a 100644 (file)
@@ -46,11 +46,13 @@ pub fn read_packages(path: &Path, source_id: &SourceId, config: &Config)
 
         // Don't recurse into git databases
         if dir.file_name().and_then(|s| s.to_str()) == Some(".git") {
-            return Ok(false);
+            return Ok(false)
         }
 
         // Don't automatically discover packages across git submodules
-        if dir != path && dir.join(".git").exists() { return Ok(false); }
+        if dir != path && fs::metadata(&dir.join(".git")).is_ok() {
+            return Ok(false)
+        }
 
         // Don't ever look at target directories
         if dir.file_name().and_then(|s| s.to_str()) == Some("target") &&
@@ -75,11 +77,13 @@ pub fn read_packages(path: &Path, source_id: &SourceId, config: &Config)
 fn walk<F>(path: &Path, callback: &mut F) -> CargoResult<()>
     where F: FnMut(&Path) -> CargoResult<bool>
 {
-    if !path.is_dir() { return Ok(()) }
+    if fs::metadata(&path).map(|m| m.is_dir()) != Ok(true) {
+        return Ok(())
+    }
 
     if !try!(callback(path)) {
         trace!("not processing {}", path.display());
-        return Ok(());
+        return Ok(())
     }
 
     // Ignore any permission denied errors because temporary directories
index 628fc7b545d01de5d5ea13abdbcfb14deaa34ee7..76ee30fb881fbee5dbd463312a41466ad57f9080 100644 (file)
@@ -119,7 +119,7 @@ pub fn prepare(pkg: &Package, target: &Target, req: Platform,
         //
         // If we have an old build directory, then just move it into place,
         // otherwise create it!
-        if !build_output.exists() {
+        if fs::metadata(&build_output).is_err() {
             try!(fs::create_dir(&build_output).chain_error(|| {
                 internal("failed to create script output directory for \
                           build command")
index cc336e1144ce5523f5e09b311c2e406ea3582983..c80d26cde2995bdca7bc96218d51d8c41535d28e 100644 (file)
@@ -59,7 +59,7 @@ pub fn prepare_target<'a, 'b>(cx: &mut Context<'a, 'b>,
     if !target.profile().is_doc() {
         for filename in try!(cx.target_filenames(target)).iter() {
             let dst = root.join(filename);
-            missing_outputs |= !dst.exists();
+            missing_outputs |= fs::metadata(&dst).is_err();
 
             if target.profile().is_test() {
                 cx.compilation.tests.push((target.name().to_string(), dst));
@@ -255,13 +255,13 @@ pub fn prepare_init(cx: &mut Context, pkg: &Package, kind: Kind)
     let new2 = new1.clone();
 
     let work1 = Work::new(move |_| {
-        if !new1.exists() {
+        if fs::metadata(&new1).is_err() {
             try!(fs::create_dir(&new1));
         }
         Ok(())
     });
     let work2 = Work::new(move |_| {
-        if !new2.exists() {
+        if fs::metadata(&new2).is_err() {
             try!(fs::create_dir(&new2));
         }
         Ok(())
index 14591df5c963fae0cd47d98139827cb840946a9f..1f6b2e50ec0ff2d1469f8e22d838311799229950 100644 (file)
@@ -46,7 +46,6 @@
 //! ```
 
 use std::fs;
-use std::io::prelude::*;
 use std::io;
 use std::path::{PathBuf, Path};
 
@@ -90,7 +89,7 @@ impl Layout {
     }
 
     pub fn prepare(&mut self) -> io::Result<()> {
-        if !self.root.exists() {
+        if fs::metadata(&self.root).is_err() {
             try!(fs::create_dir_all(&self.root));
         }
 
@@ -103,7 +102,7 @@ impl Layout {
         return Ok(());
 
         fn mkdir(dir: &Path) -> io::Result<()> {
-            if !dir.exists() {
+            if fs::metadata(&dir).is_err() {
                 try!(fs::create_dir(dir));
             }
             Ok(())
index 7553bc46de599fadc5e6d07fa76f58494d8d48d4..397e758b0531ea301565c39bb413e05337791b13 100644 (file)
@@ -1,7 +1,7 @@
 use std::collections::{HashSet, HashMap};
 use std::dynamic_lib::DynamicLibrary;
 use std::env;
-use std::ffi::{OsStr, AsOsStr, OsString};
+use std::ffi::OsString;
 use std::fs;
 use std::io::prelude::*;
 use std::path::{self, PathBuf};
@@ -368,7 +368,7 @@ fn rustc(package: &Package, target: &Target,
             //                              this manually
             for filename in filenames.iter() {
                 let dst = root.join(filename);
-                if dst.exists() {
+                if fs::metadata(&dst).is_ok() {
                     try!(fs::remove_file(&dst));
                 }
             }
@@ -662,12 +662,12 @@ fn build_deps_args(cmd: &mut CommandPrototype, target: &Target,
     let layout = cx.layout(package, kind);
     cmd.arg("-L").arg(&{
         let mut root = OsString::from_str("dependency=");
-        root.push_os_str(layout.root().as_os_str());
+        root.push(layout.root());
         root
     });
     cmd.arg("-L").arg(&{
         let mut deps = OsString::from_str("dependency=");
-        deps.push_os_str(layout.deps().as_os_str());
+        deps.push(layout.deps());
         deps
     });
 
@@ -695,12 +695,11 @@ fn build_deps_args(cmd: &mut CommandPrototype, target: &Target,
         for filename in try!(cx.target_filenames(target)).iter() {
             if filename.ends_with(".a") { continue }
             let mut v = OsString::new();
-            v.push_os_str(OsStr::from_str(target.name()));
-            v.push_os_str(OsStr::from_str("="));
-            v.push_os_str(layout.root().as_os_str());
-            let s = path::MAIN_SEPARATOR.to_string();
-            v.push_os_str(OsStr::from_str(&s));
-            v.push_os_str(OsStr::from_str(&filename));
+            v.push(target.name());
+            v.push("=");
+            v.push(layout.root());
+            v.push(&path::MAIN_SEPARATOR.to_string());
+            v.push(&filename);
             cmd.arg("--extern").arg(&v);
         }
         Ok(())
index d4faec1d8b8b62ad3f5e33e2901d3df47fa6c555..05469bf4ef47ae23f5086749698d29bc140a1a31 100644 (file)
@@ -1,4 +1,4 @@
-use std::ffi::{OsStr, OsString, AsOsStr};
+use std::ffi::OsString;
 use std::path::Path;
 
 use core::Source;
@@ -80,8 +80,8 @@ pub fn run_tests(manifest_path: &Path,
         for (pkg, libs) in compile.libraries.iter() {
             for lib in libs.iter() {
                 let mut arg = OsString::from_str(pkg.name());
-                arg.push_os_str(OsStr::from_str("="));
-                arg.push_os_str(lib.as_os_str());
+                arg.push("=");
+                arg.push(lib);
                 p.arg("--extern").arg(&arg);
             }
         }
index 8e8adfba14c644a564cc7c1ad82f3a4d044c0d2e..fbf3ea92df3d57a4efbf4cbcddc17efe0d60ecaf 100644 (file)
@@ -1,6 +1,6 @@
 use std::collections::HashMap;
 use std::env;
-use std::fs::File;
+use std::fs::{self, File};
 use std::io::prelude::*;
 use std::iter::repeat;
 use std::path::{Path, PathBuf};
@@ -109,7 +109,7 @@ fn transmit(pkg: &Package, tarball: &Path, registry: &mut Registry)
     };
     match *license_file {
         Some(ref file) => {
-            if !pkg.root().join(file).exists() {
+            if fs::metadata(&pkg.root().join(file)).is_err() {
                 return Err(human(format!("the license file `{}` does not exist",
                                          file)))
             }
index d467cbe21537e66e32be1b93feb3a79df907da72..a49d500de8137e85a7d8767458ab00e22a8b84bb 100644 (file)
@@ -150,7 +150,7 @@ impl GitRemote {
 
     fn clone_into(&self, dst: &Path) -> CargoResult<git2::Repository> {
         let url = self.url.to_string();
-        if dst.exists() {
+        if fs::metadata(&dst).is_ok() {
             try!(fs::remove_dir_all(dst));
         }
         try!(fs::create_dir_all(dst));
@@ -252,7 +252,7 @@ impl<'a> GitCheckout<'a> {
             human(format!("Couldn't mkdir {}", dirname.display()))
         }));
 
-        if into.exists() {
+        if fs::metadata(&into).is_ok() {
             try!(fs::remove_dir_all(into).chain_error(|| {
                 human(format!("Couldn't rmdir {}", into.display()))
             }));
index b64f4c1512c2f4530fdc37f76bddb7683b37c31e..6e56f9941a841fb4c5d7c7b63e71d9b2f6f1c703 100644 (file)
@@ -167,7 +167,7 @@ impl<'a, 'b> PathSource<'a, 'b> {
 
             // TODO: the `entry` has a mode we should be able to look at instead
             //       of just calling stat() again
-            if file_path.is_dir() {
+            if fs::metadata(&file_path).map(|m| m.is_dir()) == Ok(true) {
                 warn!("  found submodule {}", file_path.display());
                 let rel = file_path.relative_from(&root).unwrap();
                 let rel = try!(rel.to_str().chain_error(|| {
@@ -223,14 +223,16 @@ impl<'a, 'b> PathSource<'a, 'b> {
                    is_root: bool, filter: &mut F) -> CargoResult<()>
             where F: FnMut(&Path) -> bool
         {
-            if !path.is_dir() {
+            if fs::metadata(&path).map(|m| m.is_dir()) != Ok(true) {
                 if (*filter)(path) {
                     ret.push(path.to_path_buf());
                 }
                 return Ok(())
             }
             // Don't recurse into any sub-packages that we have
-            if !is_root && path.join("Cargo.toml").exists() { return Ok(()) }
+            if !is_root && fs::metadata(&path.join("Cargo.toml")).is_ok() {
+                return Ok(())
+            }
             for dir in try!(fs::read_dir(path)) {
                 let dir = try!(dir).path();
                 match (is_root, dir.file_name().and_then(|s| s.to_str())) {
@@ -298,7 +300,7 @@ impl<'a, 'b> Source for PathSource<'a, 'b> {
             // condition where this path was rm'ed - either way,
             // we can ignore the error and treat the path's mtime
             // as 0.
-            let mtime = file.metadata().map(|s| s.modified()).unwrap_or(0);
+            let mtime = fs::metadata(&file).map(|s| s.modified()).unwrap_or(0);
             warn!("{} {}", mtime, file.display());
             max = cmp::max(max, mtime);
         }
index c28f9f269f22b4539d3964922a7d393bb33a978a..e4e45bd5816083b33d7e868f8b4ad712ab6d5f2b 100644 (file)
@@ -301,7 +301,7 @@ impl<'a, 'b> RegistrySource<'a, 'b> {
         // TODO: should discover from the S3 redirect
         let filename = format!("{}-{}.crate", pkg.name(), pkg.version());
         let dst = self.cache_path.join(&filename);
-        if dst.exists() { return Ok(dst) }
+        if fs::metadata(&dst).is_ok() { return Ok(dst) }
         try!(self.config.shell().status("Downloading", pkg));
 
         try!(fs::create_dir_all(dst.parent().unwrap()));
@@ -347,7 +347,7 @@ impl<'a, 'b> RegistrySource<'a, 'b> {
                       -> CargoResult<PathBuf> {
         let dst = self.src_path.join(&format!("{}-{}", pkg.name(),
                                               pkg.version()));
-        if dst.join(".cargo-ok").exists() { return Ok(dst) }
+        if fs::metadata(&dst.join(".cargo-ok")).is_ok() { return Ok(dst) }
 
         try!(fs::create_dir_all(dst.parent().unwrap()));
         let f = try!(File::open(&tarball));
index ad8f359d31d80a2de5109c2946fdf604bab9e8f6..7677da2dad4477a737fec15f73d78a2936e82326 100644 (file)
@@ -393,7 +393,7 @@ fn walk_tree<F>(pwd: &Path, mut walk: F) -> CargoResult<()>
 
     loop {
         let possible = current.join(".cargo").join("config");
-        if possible.exists() {
+        if fs::metadata(&possible).is_ok() {
             let file = try!(File::open(&possible));
 
             try!(walk(file, &possible));
@@ -413,7 +413,7 @@ fn walk_tree<F>(pwd: &Path, mut walk: F) -> CargoResult<()>
     }));
     if !pwd.starts_with(&home) {
         let config = home.join("config");
-        if config.exists() {
+        if fs::metadata(&config).is_ok() {
             let file = try!(File::open(&config));
             try!(walk(file, &config));
         }
index 7facb0980a66739d3ec85a080101df2684e24b01..365ddabe3e383f20d6764c1ffe5df79e69a841fb 100644 (file)
@@ -1,5 +1,5 @@
 use std::env;
-use std::io::prelude::*;
+use std::fs;
 use std::path::{Path, PathBuf};
 use util::{CargoResult, human, ChainError};
 
@@ -20,7 +20,7 @@ pub fn find_project_manifest(pwd: &Path, file: &str) -> CargoResult<PathBuf> {
 
     loop {
         let manifest = current.join(file);
-        if manifest.exists() {
+        if fs::metadata(&manifest).is_ok() {
             return Ok(manifest)
         }
 
@@ -50,7 +50,7 @@ pub fn find_root_manifest_for_cwd(manifest_path: Option<String>)
 pub fn find_project_manifest_exact(pwd: &Path, file: &str) -> CargoResult<PathBuf> {
     let manifest = pwd.join(file);
 
-    if manifest.exists() {
+    if fs::metadata(&manifest).is_ok() {
         Ok(manifest)
     } else {
         Err(human(format!("Could not find `{}` in `{}`",
index 80a80e776b502aa19c1ccd66675271990e03b0c1..35e130418be88deb2cc214b209ebc2f9b789f617 100644 (file)
@@ -44,7 +44,7 @@ impl Layout {
 }
 
 fn try_add_file(files: &mut Vec<PathBuf>, file: PathBuf) {
-    if file.exists() {
+    if fs::metadata(&file).is_ok() {
         files.push(file);
     }
 }
@@ -72,7 +72,7 @@ pub fn project_layout(root_path: &Path) -> Layout {
     let mut benches = vec!();
 
     let lib_canidate = root_path.join("src").join("lib.rs");
-    if lib_canidate.exists() {
+    if fs::metadata(&lib_canidate).is_ok() {
         lib = Some(lib_canidate);
     }
 
index d6022b12716ad0e3a95872b90ce0947619a58ef2..93b94b66cd361c3bdc2721b017c9d561aee74d63 100644 (file)
@@ -1,4 +1,4 @@
-#![feature(core, io, path, fs)]
+#![feature(io, path)]
 
 extern crate curl;
 extern crate "rustc-serialize" as rustc_serialize;
@@ -142,14 +142,14 @@ impl Registry {
                 (json.len() >>  8) as u8,
                 (json.len() >> 16) as u8,
                 (json.len() >> 24) as u8,
-            ].iter().cloned());
-            w.extend(json.as_bytes().iter().cloned());
+            ].iter().map(|x| *x));
+            w.extend(json.as_bytes().iter().map(|x| *x));
             w.extend([
                 (stat.len() >>  0) as u8,
                 (stat.len() >>  8) as u8,
                 (stat.len() >> 16) as u8,
                 (stat.len() >> 24) as u8,
-            ].iter().cloned());
+            ].iter().map(|x| *x));
             w
         };
         let tarball = try!(File::open(tarball).map_err(Error::Io));
@@ -158,7 +158,10 @@ impl Registry {
 
         let url = format!("{}/api/v1/crates/new", self.host);
 
-        let token = try!(self.token.as_ref().ok_or(Error::TokenMissing));
+        let token = match self.token.as_ref() {
+            Some(s) => s,
+            None => return Err(Error::TokenMissing),
+        };
         let request = self.handle.put(url, &mut body)
             .content_length(size)
             .header("Accept", "application/json")
@@ -209,7 +212,10 @@ impl Registry {
                               .content_type("application/json");
 
         if authorized == Auth::Authorized {
-            let token = try!(self.token.as_ref().ok_or(Error::TokenMissing));
+            let token = match self.token.as_ref() {
+                Some(s) => s,
+                None => return Err(Error::TokenMissing),
+            };
             req = req.header("Authorization", &token);
         }
         match body {
index ac5240e643fae49f7bea9dc31a200fca1b0341bd..427618d484781ca74ed278d6481f41e165d5dc01 100644 (file)
@@ -1 +1 @@
-2015-03-04
+2015-03-09